-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix Predicate Pushdown: split_members should be able to split aliased predicate #1368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
cc @Dandandan |
| Projection: #test.a\ | ||
| \n Filter: NOT #test.c AS test.c = Boolean(false)\ | ||
| \n Filter: #test.b AS test.b = Boolean(true)\ | ||
| \n Filter: NOT #test.c\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
thanks @viirya for the quick change / PR! I think this is a good change. I am wondering if there's more places where we don't want to add an alias. Also we probably need some more tests to cover filter pushdown in combination with other optimization passes like this one. Another thing to consider might be for the filter operation to ignore the alias. FYI @alamb WDYT |
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand how aliases can mess up filter push down (perhaps filter pushdown should be stripping off the aliases)?
| } else { | ||
| Ok(new_e) | ||
| match plan { | ||
| LogicalPlan::Filter { .. } => Ok(new_e), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to recommend adding a comment here about why we don't add aliases for filter.
|
Yeah, I suggest:
I "feel" like there should be nothing wrong with aliasing the output of a |
|
Thanks. I'm adding a test for TPCH plans. I will take a look on Filter pushdown with aliases later. |
|
Currently the filter_push_down rule fails on TPCH q10 with aliased on Filter because By adding |
This reverts commit f07cbdd.
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn tpch_explain_q10() -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
Maybe it would be good to have those in the tpch crate instead?
In that case we could include some / all other queries as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree -- filed #1377 to track this
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @viirya !
Would it be possible to move the tpch tests into the tpch crate, as suggested by @Dandandan as part of this PR?
Someone can add explain plans for the other TPCH queries as part of #1377 so I don't think that is necessary.
Thanks for sticking with this one and finding the elegant solution
| split_members(left, predicates); | ||
| split_members(right, predicates); | ||
| } | ||
| Expr::Alias(expr, _) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 excellent
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn tpch_explain_q10() -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree -- filed #1377 to track this
| \n Join: #customer.c_custkey = #orders.o_custkey\ | ||
| \n TableScan: customer projection=Some([0, 1, 2, 3, 4, 5, 7])\ | ||
| \n Filter: #orders.o_orderdate >= Date32(\"8674\") AND #orders.o_orderdate < Date32(\"8766\")\ | ||
| \n TableScan: orders projection=Some([0, 1, 4]), filters=[#orders.o_orderdate >= Date32(\"8674\"), #orders.o_orderdate < Date32(\"8766\")]\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so lovely to see those filters pushed down ❤️
|
Thanks @alamb @Dandandan ! Yeah, if I find some time later to (or someone can) add tests for the other TPCH queries, we can move the test together. |
Which issue does this PR close?
Closes #1367.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?